package com.accp.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.accp.pojo.Manuscript;
import com.accp.pojo.Result;
import com.accp.repository.ManuscriptRepository;
import com.accp.service.ManuscriptService;

@Service("manuscriptServiceImpl")
public class ManuscriptServiceImpl implements ManuscriptService {
	@Resource
	private ManuscriptRepository manuscriptRepository;

	@Override
	public int addManuscript(Manuscript manuscript) {
		return manuscriptRepository.addManuscript(manuscript);
	}

	@Override
	public Result getManuscript(Manuscript manuscript) {
		int startIndex = (manuscript.getPageIndex() - 1) * manuscript.getPageNum();
		manuscript.setStartIndex(startIndex);
		List<Manuscript> manuscriptList = manuscriptRepository.getManuscript(manuscript);
		Result result = new Result();
		result.setCode(1);
		result.setMsg("ok");
		result.setObj(manuscriptList);
		result.setTotal(manuscriptRepository.count(manuscript));
		return result;
	}

	@Override
	public int uptManuscript(Manuscript manuscript) {
		return manuscriptRepository.uptManuscript(manuscript);
	}

	@Override
	public int count(Manuscript manuscript) {
		return manuscriptRepository.count(manuscript);
	}

}
